package com.atguigu.cloud.controller;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.atguigu.cloud.apis.PayFeignApi;
import com.atguigu.cloud.entities.PayDTO;
import com.atguigu.cloud.resp.ResultData;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: OrderFeginController
 * Package: com.atguigu.cloud.controller
 * Description:
 *
 * @Author 加油-ssj
 * @Create 2025/3/21 16:26
 * @Version 1.0
 */
@RestController
public class OrderFeginController {

    @Resource
    private PayFeignApi payFeignApi;

    @PostMapping("/fegin/pay/add")
    public ResultData addPay(@RequestBody PayDTO payDTO){

        ResultData resultData = payFeignApi.addPay(payDTO);
        return resultData;
    }

    @DeleteMapping("/fegin/pay/del/{id}")
    public ResultData deletePay(@PathVariable("id") Integer id){

        ResultData resultData = payFeignApi.deletePay(id);
        return resultData;
    }

    @PutMapping("/fegin/pay/update")
    public ResultData updatePay(@RequestBody PayDTO payDTO){

        return payFeignApi.updatePay(payDTO);
    }

    @GetMapping("/fegin/pay/get/{id}")
    public ResultData getPay(@PathVariable("id") Integer id){

        return payFeignApi.getPay(id);
    }

    @GetMapping("/fegin/pay/getAll")
    public ResultData getAllPay(){


        try {
            System.out.println("方法开始计时"+ DateUtil.now());
            return payFeignApi.getAll();
        } catch (Exception e) {
            System.out.println("方法结束"+DateUtil.now());
            throw new RuntimeException(e);
        }
    }

    @GetMapping("/fegin/pay/get/info")
    public String getInfo(){

        return payFeignApi.getInfo();
    }



}
